#include "DialogBar.h"
#include "CanvasWnd.h"

CDialogBar::CDialogBar()
{
    m_pCanvas = NULL;
}

LRESULT CDialogBar::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    HWND slider = GetDlgItem(IDR_SPEEDSLIDER);
    m_speed.Attach(slider);
    m_speed.SetRange(MIN_SPEED, MAX_SPEED);
    m_speed.SetPos(MAX_SPEED);
    bHandled = TRUE;
    return TRUE;
}

LRESULT CDialogBar::OnHScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{

    if (LOWORD(wParam) == SB_THUMBPOSITION) {
        WORD pos = HIWORD(wParam);
        if (m_pCanvas) {
            m_pCanvas->SetDelay((MAX_SPEED-pos) );
        }
    }
    return 0;
}

void CDialogBar::SetCanvasWnd(CCanvasWnd* pCanvas)
{
    m_pCanvas = pCanvas;
}
